package com.lzx.httpclient;

import java.io.File;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;

public class MultpartTest {
	
	public static void main(String[] args) throws Exception {
		
		URL url = new URL("http://localhost:8080/FileUpload/uploadAction.do");
		HttpPost hp = new HttpPost(url);
		//�添加头部信息
		hp.getHeaderGroup().addHeader("Referer", "http://www.baidu.com/s?wd=Content-Length+%BC%C6%CB%E3&n=2");
//		hp.getHeaderGroup().addHeader("Cookie", "BAIDUID=D31665FD7DE1FD8D7549AB5AE00790F5:FG=1");
		
		//文件
		FileBody fileBody = new FileBody(new File("c:/中文utilizare_java_web_start.pdf"), "uploadFile");
		hp.addField(fileBody);
		//
		StringBody stringBody = new StringBody("name", "linzhixian林志贤");
		hp.addField(stringBody);	

		
		//执行上传
		hp.execute();
		
		
	}

}
